<template>
  <div>
    <div class="HistoryHot-body">
      <div class="History-list" v-show="isShow">
        <div class="hd">
          <h4>历史记录</h4>
          <van-icon name="delete-o" @click="clearHistory" />
        </div>
        <div class="tb">
          <van-tag
            plain
            type="default"
            v-for="(item, index) in historyKeywordList"
            :key="index"
            @click="tagsearch(item)"
            >{{ item }}</van-tag
          >
        </div>
      </div>
      <div class="Hot-list">
        <div class="hd">
          <h4>热门搜索</h4>
        </div>
        <div class="tb">
          <van-tag
            plain
            :type="m.is_hot === 1 ? 'danger' : 'default'"
            v-for="(m, idx) in hotKeywordList"
            :key="idx"
            @click="tagsearch(m.keyword)"
            >{{ m.keyword }}</van-tag
          >
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { clearHistory } from "@/request/api";
export default {
  props: ["historyKeywordList", "hotKeywordList"],
  data() {
    return {
      isShow:true
    };
  },
  created() {},
  mounted() {},
  methods: {
    //点击内容，搜索列表
    tagsearch(val) {
      this.$emit("tagsearch", val);
    },
    clearHistory() {
      clearHistory().then((res) => {
        // console.log(res);
        //this.$toast，在弹窗层级不能给太高，不然不显示
        this.$toast.success("删除成功");
        setTimeout(() => {
          this.isShow = false;
        }, 1000);
      });
    },
  },
};
</script>

<style scoped lang="less">
.HistoryHot-body {
  .History-list {
    background-color: #fff;
    padding: 0 0.1rem;
    margin-bottom: 0.2rem;
  }
  .hd {
    display: flex;
    font-size: 0.18rem;
    display: flex;
    justify-content: space-between;
  }
  .tb {
    margin: 0.1rem 0;
    .van-tag {
      margin-right: 0.1rem;
      padding: 0.02rem 0.04rem;
      margin-bottom: 0.1rem;
    }
  }
  .Hot-list {
    
    background-color: #fff;
    padding: 0.1rem 0.1rem 0;
  }
}
</style>
